#include "widget.h"
#include "ui_widget.h"
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_textEdit_selectionChanged()
{
    QTextCursor cursor=ui->textEdit->textCursor();
    qDebug()<<"selectionChanged: "<<cursor.selectedText();//打印选中的内容
}

void Widget::on_textEdit_cursorPositionChanged()
{
    //光标位置改变触发
    QTextCursor cursor=ui->textEdit->textCursor();
    qDebug()<<"cursorPositionChanged"<<cursor.position();
}
